home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_cyrus-sasl.idb / usr / freeware / include / hmac-md5.h.z / hmac-md5.h
C/C++ Source or Header  |  2001-07-06  |  1KB  |  52 lines

  1. /* hmac-md5.h -- HMAC_MD5 functions
  2.  */
  3.  
  4. #ifndef HMAC_MD5_H
  5. #define HMAC_MD5_H 1
  6.  
  7. #define HMAC_MD5_SIZE 16
  8.  
  9. /* intermediate MD5 context */
  10. typedef struct HMAC_MD5_CTX_s {
  11.     MD5_CTX ictx, octx;
  12. } HMAC_MD5_CTX;
  13.  
  14. /* intermediate HMAC state
  15.  *  values stored in network byte order (Big Endian)
  16.  */
  17. typedef struct HMAC_MD5_STATE_s {
  18.     UINT4 istate[4];
  19.     UINT4 ostate[4];
  20. } HMAC_MD5_STATE;
  21.  
  22. /* One step hmac computation
  23.  *
  24.  * digest may be same as text or key
  25.  */
  26. void hmac_md5(const unsigned char *text, int text_len,
  27.           const unsigned char *key, int key_len,
  28.           unsigned char digest[HMAC_MD5_SIZE]);
  29.  
  30. /* create context from key
  31.  */
  32. void hmac_md5_init(HMAC_MD5_CTX *hmac,
  33.            const unsigned char *key, int key_len);
  34.  
  35. /* precalculate intermediate state from key
  36.  */
  37. void hmac_md5_precalc(HMAC_MD5_STATE *hmac,
  38.               const unsigned char *key, int key_len);
  39.  
  40. /* initialize context from intermediate state
  41.  */
  42. void hmac_md5_import(HMAC_MD5_CTX *hmac, HMAC_MD5_STATE *state);
  43.  
  44. #define hmac_md5_update(hmac, text, text_len) MD5Update(&(hmac)->ictx, (text), (text_len))
  45.  
  46. /* finish hmac from intermediate result.  Intermediate result is zeroed.
  47.  */
  48. void hmac_md5_final(unsigned char digest[HMAC_MD5_SIZE],
  49.             HMAC_MD5_CTX *hmac);
  50.  
  51. #endif /* HMAC_MD5_H */
  52.